package com.yipin.neimeng.vo;

import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;

/**
 * @author feiniu
 * @date 2024/3/28 15:28
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class ResultMsg<T> implements Serializable {
    private static final long serialVersionUID = 1L;

    private Integer code;

    private String msg;

    private T data;

    public ResultMsg() {
    }

    public ResultMsg(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
        this.data = null;
    }

    public ResultMsg(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static ResultMsg success(Integer code, String msg) {
        return new ResultMsg<>(code, msg);
    }

    public static <T> ResultMsg<T> success(Integer code, String msg, T data) {
        return new ResultMsg<>(code, msg, data);
    }

    public static <T> ResultMsg<T> fail(Integer code, String msg, T data) {
        return new ResultMsg<>(code, msg, data);
    }

    public static <T> ResultMsg<T> fail(Integer code, String msg) {
        return new ResultMsg<>(code, msg, null);
    }
}
